import { Component, OnInit } from '@angular/core';
import { TodoList, DataFlow, DataFlowPracticeService } from './data-flow-practice.service';
import { BehaviorSubject } from 'rxjs';

@Component({
  selector: 'app-data-flow-practice',
  templateUrl: './data-flow-practice.component.html',
  styleUrls: ['./data-flow-practice.component.sass']
})
export class DataFlowPracticeComponent implements OnInit {
  todoList: TodoList[];
  dataFlowSubject: BehaviorSubject<DataFlow>;

  constructor(private dataFlowService: DataFlowPracticeService) {
    this.dataFlowSubject = this.dataFlowService.dataFlowSubject;
  }

  ngOnInit(): void {
    this.dataFlowSubject.subscribe((data: DataFlow) => this.todoList = data.list)
    console.log(this.todoList);
  }
  changeAddText = (event: Event): void => {
    const value = (event.target as HTMLInputElement).value;
  }
  addTodo(): void { }
}
